//
//  MYGSelectDoctorTableViewCell.swift
//  MYDoctor
//
//  Created by Denny on 2024/5/7.
//

import UIKit

class MYGSelectDoctorCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    var model: MYGFriendModel = MYGFriendModel() {
        didSet {
            self.usernameLB.text = model.name
            self.avatar.sd_setImage(with: URL(string: model.avatar), placeholderImage: UIImage.init(named: "head"), context: nil)
            self.jobLabel.text = " " + model.department + " "
            self.jobLabel.isHidden = model.department.count == 0
            self.contentLB.text = model.hospital
            self.selectBtn.isSelected = model.selected
        }
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        addSubview(selectBtn)
        selectBtn.snp.makeConstraints { make in
            make.size.equalTo(CGSize.init(width: 40, height: 40))
            make.left.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        addSubview(avatar)
        avatar.snp.makeConstraints { make in
            make.size.equalTo(CGSize.init(width: 50, height: 50))
            make.centerY.equalToSuperview()
            make.left.equalTo(selectBtn.snp.right)
        }
        addSubview(usernameLB)
        usernameLB.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(15)
            make.left.equalTo(avatar.snp.right).offset(5)
            make.height.equalTo(25)
        }
        addSubview(jobLabel)
        jobLabel.snp.makeConstraints { make in
            make.centerY.equalTo(usernameLB.snp.centerY)
            make.left.equalTo(usernameLB.snp.right).offset(5)
        }
        
        addSubview(contentLB)
        contentLB.snp.makeConstraints { make in
            make.top.equalTo(usernameLB.snp.bottom).offset(5)
            make.left.equalTo(avatar.snp.right).offset(5)
            make.right.equalToSuperview().offset(-25)
//            make.bottom.equalToSuperview()
        }
        addSubview(line)
        line.snp.makeConstraints { make in
            make.top.equalTo(contentLB.snp.bottom).offset(14)
            make.bottom.equalToSuperview()
            make.right.equalToSuperview()
            make.left.equalTo(avatar.snp.right).offset(5)
            make.height.equalTo(0.5)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var avatar:UIImageView = {
        let control = UIImageView()
        control.layer.cornerRadius = 4
        control.layer.masksToBounds = true
        return control
    }()
    
    var usernameLB:UILabel = {
        let control = UILabel()
        control.textColor = UIColor.init(hexString: "#2C2C2C")
        control.font = .medium(16)
        return control
    }()
    
    var contentLB:UILabel = {
        let control = UILabel()
        control.textColor = UIColor.init(hexString: "#808080")
        control.font = .regular(13)
        control.numberOfLines = 0
        return control
    }()
    
    var jobLabel:UILabel = {
        let control = UILabel()
        control.textColor = UIColor.init(hexString: "#1772EF")
        control.layer.cornerRadius = 2
        control.layer.borderColor = UIColor.init(hexString: "#1772EF").cgColor
        control.layer.masksToBounds = true
        control.layer.borderWidth = 0.5
        control.font = .regular(12)
        control.backgroundColor = .white
        return control
    }()
    
    var line: UIView = {
        let control = UIView()
        control.backgroundColor = UIColor.init(hexString: "#eeeeee")
        return control
    }()
    
    var selectBtn: UIButton = {
        let contorl = UIButton()
        contorl.setImage(UIImage.init(named: "MYG_cloudDisk_content_normal"), for: .normal)
        contorl.setImage(UIImage.init(named: "MYG_cloudDisk_content_selected"), for: .selected)
        contorl.setImage(UIImage.init(named: "MYG_cloudDisk_content_selected"), for: .highlighted)
        return contorl
    }()
}

